package org.changwang.Map;

import java.util.HashMap;
import java.util.Map;

/**
 * @ClassName MapClear
 * @Description
 * @Author c.w
 * @Date 2025/6/30 18:17
 * @Version 1.0.0
 */
public class MapClear {
	public static void main(String[] args) {
		MapItem mapItem1 = new MapItem("1");
		MapItem mapItem2 = new MapItem("2");
		MapItem mapItem3 = new MapItem("3");
		Map<String, MapItem> map1 = new HashMap<String, MapItem>();
		map1.put("1", mapItem1);
		map1.put("2", mapItem2);
		map1.put("3", mapItem3);

		Map<String, MapItem> map2 = new HashMap<String, MapItem>();
		map2.put("1", mapItem1);
		map2.put("2", mapItem2);
		map2.put("3", mapItem3);
		System.out.println("map1:");
		for (Map.Entry<String, MapItem> entry : map1.entrySet()){
			System.out.println(entry.getKey() + ":" + entry.getValue().getName());
		}
		map1.clear();
		System.out.println("map1 clear:");
		for (Map.Entry<String, MapItem> entry : map1.entrySet()){
			System.out.println(entry.getKey() + ":" + entry.getValue().getName());
		}

		System.out.println("map2:");
		for (Map.Entry<String, MapItem> entry : map2.entrySet()){
			System.out.println(entry.getKey() + ":" + entry.getValue().getName());
		}
	}


	public static void clearTest() {

	}
}

class MapItem{
	String name;

	public MapItem(String name) {
		this.name = name;
	}
	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

}